﻿CREATE TABLE [dbo].[BemanningGrupp] (
    [Id]         UNIQUEIDENTIFIER NOT NULL,
    [ValId]      UNIQUEIDENTIFIER NOT NULL,
    [Skapad]     DATETIME         NOT NULL,
    [SkapadAv]   NVARCHAR (50)    NOT NULL,
    [Andrad]     DATETIME         NULL,
    [AndradAv]   NVARCHAR (50)    NULL,
    [PersonId]   UNIQUEIDENTIFIER NULL,
    [FunktionId] UNIQUEIDENTIFIER NOT NULL,
    [GruppId]    UNIQUEIDENTIFIER NOT NULL,
    [TackatJa]   BIT              NOT NULL,
    CONSTRAINT [PK_BemanningGrupp] PRIMARY KEY CLUSTERED ([Id] ASC, [ValId] ASC),
    CONSTRAINT [FK_BemanningGrupp_Funktion] FOREIGN KEY ([FunktionId], [ValId]) REFERENCES [dbo].[Funktion] ([Id], [ValId]),
    CONSTRAINT [FK_BemanningGrupp_Grupp] FOREIGN KEY ([GruppId], [ValId]) REFERENCES [dbo].[Grupp] ([Id], [ValId]),
    CONSTRAINT [FK_BemanningGrupp_Person] FOREIGN KEY ([PersonId], [ValId]) REFERENCES [dbo].[Person] ([Id], [ValId])
);



